
# 定义类
class Perosn:

    def __init__(self, name):
        self.name = name
        # 私有属性, 外部不能直接访问
        self.__age =  18

    def set_addr(self, addr):
        self.addr = addr;

    def get_addr(self):
        return self.addr

    def say(self):
        print(self.name + " say")

    def eat(self):
        print(self.name + " eat")

    # 私有方法, 外部不能直接访问
    def __secret(self):
        print("秘密")

    def __str__(self):
        return "name is "+ self.name

    def __del__(self):
        print("del")

# 创建对象
person = Perosn("sn")
person.say()
person.eat()
person.set_addr("郑州市")
print(person) # name is sn


